package org.dtrd.modules.patient.entity.bean.report;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveBasic;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveBasicFamily;
import org.dtrd.modules.patient.entity.po.DtrdEntRdPatient;

import java.util.Date;

/**
 * <p>
 * 患者表
 * </p>
 *
 * @author QR
 * @since 2022-01-18
 */
@Data
@ApiModel(value = "患者基础信息")
public class PatientBasicInfo {

    @ApiModelProperty("患者姓名")
    private String patientsName;

    @ApiModelProperty("手机号码")
    private String patientsMobile;

    @ApiModelProperty("出生日期")
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    private Date patientsBirthday;

    @ApiModelProperty("患者年龄")
    private Integer patientAge;

    @ApiModelProperty("性别")
    private String patientsSex;

    @ApiModelProperty("患者位置")
    private String patientsLocation;

    @ApiModelProperty("职业：1-轻体力劳动,2-中体力劳动,3-重体力劳动")
    private String occupation;

    @ApiModelProperty("文化程度：1-未读,2-小学,3-初中,4-高中,5-中专,6-大专,7-本科,8-硕士或硕士以上")
    private String education;

    @ApiModelProperty("患者属性：1-门诊,2-住院")
    private String patientProperty;

    @ApiModelProperty("医疗支付方式：1-社会医疗基本保险,2-新型农村合作医疗保险,3-城镇居民医疗保险,4-商业保险,5-公费医疗,6-自费医疗,7-其它")
    private String payMode;

    @ApiModelProperty("家属")
    private String familyNumber;

    @ApiModelProperty("家属电话")
    private String familyNumberPhone;

    @ApiModelProperty("患者主诉")
    private String patientDesc;

    @ApiModelProperty("身高")
    private String height;

    @ApiModelProperty("体重")
    private String weight;

    @ApiModelProperty("年龄")
    private Float bmi;

    @ApiModelProperty("体型照片")
    private String patientBodyImage;

    public PatientBasicInfo parseFromPO(DtrdEntRdArchiveBasicFamily po) {
        Integer familyRelation = po.getFamilyRelation();
        String familyName = po.getFamilyName();
        if (familyRelation != null && StrUtil.isNotBlank(familyName)) {
            String name = Constant.FamilyRelation.valueOf(familyRelation).getName();
            familyNumber = name + ": " + familyName;
        }
        familyNumberPhone = po.getFamilyMobile();
        return this;
    }


    public PatientBasicInfo parseFromPO(DtrdEntRdArchiveBasic po) {
        if (po.getOccupation() != null) {
            occupation = Constant.Occupation.valueOf(po.getOccupation()).getName();
        }
        if (po.getEducation() != null) {
            education = Constant.Education.valueOf(po.getEducation()).getName();
        }
        if (po.getPatientProperty() != null) {
            patientProperty = Constant.PatientProperty.valueOf(po.getPatientProperty()).getName();
        }
        if (po.getPayMode() != null) {
            payMode = Constant.PayMode.valueOf(po.getPayMode()).getName();
        }
        if (po.getPatientBodyImage() != null) {
            patientBodyImage = po.getPatientBodyImage();
        }
        return this;
    }

    public PatientBasicInfo parseFromPO(DtrdEntRdPatient po) {
        patientsMobile = po.getPatientsMobile();
        patientsName = po.getPatientsName();
        if (po.getPatientsBirthday() != null) {
            patientsBirthday = po.getPatientsBirthday();
            patientAge = DateUtil.ageOfNow(po.getPatientsBirthday());
        }
        if (po.getPatientsSex() != null) {
            patientsSex = Constant.Sex.valueOf(po.getPatientsSex()).getName();
        }
        patientDesc = po.getPatientsDescription();
        return this;
    }

}
